package com.webchat.pgc;

import com.webchat.common.util.SpringContextUtil;
import com.webchat.pgc.messagequeue.consumer.ArticlePushDelayQueueConsumer;
import com.webchat.pgc.messagequeue.consumer.redis.MallProductStockUpdateRedisQueue;
import com.webchat.pgc.messagequeue.local.MQTaskWriteDataBaseQueue;
import com.webchat.rmi.annotation.EnableRpcPermissionFilter;
import com.webchat.rmi.annotation.EnableRpcPermissionInterceptor;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableScheduling;


@SpringBootApplication
@EnableDiscoveryClient
@ComponentScan("com.webchat")
@EnableFeignClients("com.webchat.rmi")
@EnableRpcPermissionInterceptor
@EnableRpcPermissionFilter
public class WebchatPGCApplication {

    public static void main(String[] args) {
        SpringApplication.run(WebchatPGCApplication.class, args);

        new Thread(() -> SpringContextUtil.getBean(ArticlePushDelayQueueConsumer.class).schedule()).start();

        new Thread(() -> SpringContextUtil.getBean(MallProductStockUpdateRedisQueue.class).schedule()).start();

        new Thread(() -> SpringContextUtil.getBean(MQTaskWriteDataBaseQueue.class).execConsume()).start();
    }

}
